package com.qf.lanzhou.blog.api.controller.login;

import com.qf.lanzhou.blog.api.controller.BaseServletPost;
import com.qf.lanzhou.blog.api.service.ForgetPasswordService;
import com.qf.lanzhou.blog.api.service.impl.login.ForgetPasswordServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author LEON-HE
 */
@WebServlet("/checkCode.do")
public class SendMsgToAdminServlet extends BaseServletPost {
    private ForgetPasswordService forgetPasswordService = new ForgetPasswordServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("开始发送");
        String username = req.getParameter("username");
        try{
            System.out.println(username);
            forgetPasswordService.updateAudit(username);
            successResultWrite(null,resp);
        }catch(RuntimeException e){
            String errorMsg = e.getMessage();
            failedResultWrite(errorMsg,resp);
            e.printStackTrace();
        }
    }
}
